import Vue from 'vue'
import VueRouter from 'vue-router'
import BookSearch from '../views/BookSearch'
import BookAdd from '../views/BookAdd'
import BookUpdate from '../views/BookUpdate'
import Index from '../views/Index'

Vue.use(VueRouter)

const routes = [
  {
    path: '/', // ’/'为项目的根目录
    name: '图书管理',
    component: Index, //父组件
    redirect: '/book', // 重定向为渲染的路径
    show: true,
    children: [
      {
        path: '/book',
        name: '查询图书',
        component: BookSearch
      },
      {
        path: '/addBook',
        name: '添加图书',
        component: BookAdd
      },
    ]
  },
  {
    path: '/22', // ’/'为项目的根目录
    name: '图书管理2',
    component: Index, //父组件
    show: false,
    children: [
      {
        path: '/updateBook',
        name: '修改图书',
        component: BookUpdate
      }
    ]
  }


]

const router = new VueRouter({
  // mode: 'history', 将这注释掉就是默认的hash模式了
  base: process.env.BASE_URL,
  routes
})

export default router
